package AnaliseSemantica;

import java.util.ArrayList;
import java.util.HashMap;
import Erros.ErrorMsg;
import ArvoreSintatica.*;

public class Classe {
	
	private Simbolo name;	
	private Type tipo;	
	private HashMap<Simbolo, Type> variaveis;	
	private HashMap<Simbolo, Metodo> metodos;	
	private Simbolo extender;
	
	/***/
	public Classe(Simbolo name){
		this.name = name;
		tipo = new IdentifierType(name.toString());
		variaveis = new HashMap<Simbolo, Type>();
		metodos = new HashMap<Simbolo, Metodo>();
		extender = null;
	}
	
	/***/
	public Classe(Simbolo name, Simbolo ext){
		this.name = name;
		tipo = new IdentifierType(name.toString());
		variaveis = new HashMap<Simbolo, Type>();
		metodos = new HashMap<Simbolo, Metodo>();
		extender =  null;
		if (name.equals(ext)) {
			extender = ext;
			ErrorMsg.complain("Classe: "+ name.toString()+" esta estendendo ela mesma");
		}
	}
	
	/***/
	public boolean compare(Classe s){
		return this.name.equals(s.name);
	}

	/***/
	public void addMethod(Simbolo m, Type returnType, ArrayList<String> arguments) {
		Metodo mt = new Metodo(m, returnType, arguments);
		metodos.put(m, mt);
	}

	/***/
	public void addVariable(Simbolo variable, Type type2) {
		variaveis.put(variable, type2);
	}

	/***/
	public Metodo getMethod(Simbolo meth) {
		return metodos.get(meth);
	}

	/***/
	public Simbolo getName() {
		return name;
	}
	
	/***/
	public HashMap<Simbolo, Type> getVariables(){
		return variaveis;
	}

	/***/
	public HashMap<Simbolo, Metodo> getMethods() {
		return metodos;
	}

	/***/
	public Simbolo getExtender() {
		return extender;
	}
	
	/***/
	public Type getType(){
		return tipo;
	}
	
	/***/
	public int getNumberOfVariables(){
		return variaveis.size();
	}
	
}
